﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using com.pro2e.console.service.auth.dao;
using System.Collections.Generic;
using com.pro2e.console.service.auth.vo;
using com.pro2e.web.treeview;
using com.pro2e.console.service.auth;
using com.pro2e.web.util.page;
using com.pro2e.console.core.util;
using System.IO;
using com.pro2e.web.config;
using com.pro2e.web.util;
public partial class activityAdmin_leftmenu : System.Web.UI.Page
{
    log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    SessionHelper sHelper = new SessionHelper();
    AuthService authService = new AuthService();
    ConfigHelper configHelper = new ConfigHelper();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            initMenu();

            new TreeViewState().RestoreTreeView(tvMenu, this.GetType().ToString());

        }
    }

    private void initMenu()
    {
        LoginUser user = sHelper.LoginUser;

        if (user == null)
        {
            Response.Redirect("~/activityAdmin/Login/Error.aspx", false);
            return;
        }
        TreeNode treeNode = new TreeNode("天天真幸福活動", "1", "", "welcome.aspx", "mainfrm");
        TreeNode subTreeNode = new TreeNode("問卷統計報表", null, null, "~/activityAdmin/UC01/Statistics.aspx", "mainfrm");
        treeNode.ChildNodes.Add(subTreeNode);
        TreeNode subTreeNode2 = new TreeNode("徵文報表匯出", null, null, "~/activityAdmin/UC01/Export01.aspx", "mainfrm");
        treeNode.ChildNodes.Add(subTreeNode2);
        tvMenu.Nodes.Add(treeNode);
        tvMenu.Nodes[0].Expand();
        tvMenu.DataBind();
    }
    protected void tvMenu_SelectedNodeChanged(object sender, EventArgs e)
    {
  
        if (tvMenu.SelectedNode.Value != string.Empty)
        {
            Response.Redirect("~/" + tvMenu.SelectedNode.Value, false);
        }
    }
    protected void tvMenu_Unload(object sender, EventArgs e)
    {
        //  log.Debug("enter tvMenu_Unload");
        new TreeViewState().SaveTreeView(tvMenu, this.GetType().ToString());
    }
    
    protected void btnLogout_Click(object sender, ImageClickEventArgs e)
    {
        sHelper.LoginUser = null;

        Response.Redirect("~/activityAdmin/Login/Error.aspx", false);
        return;
    }
    protected void btnLogout_Click1(object sender, EventArgs e)
    {

        logout();
    }
    protected void btnLogout_Click1(object sender, ImageClickEventArgs e)
    {
        logout();
    }
    private void logout()
    {
        sHelper.LoginUser = null;
        Session.Clear();
        string url = string.Format("top.document.location.href='http://{0}';", configHelper.Host);
        return;
    }

}
